<?php


/**
 * +-------------------------------------------------------------
 * |Caption:
 * +-------------------------------------------------------------
 * |Author: Lenny
 * +-------------------------------------------------------------
 * |Email:  1685964109@qq.com
 * +-------------------------------------------------------------
 * |Date:   2024-03-12 09:42
 * +-------------------------------------------------------------
 */

use app\service\middleware\CheckDomain;
use think\facade\Route;
use app\service\middleware\LoginLimit;
use app\service\middleware\Token;

//登录
Route::group('login', function () {
    Route::post('login', 'login/login');//登录
//    Route::post('login', 'login/login')->middleware(LoginLimit::class);//登录
    Route::get('captcha', 'login/captcha');//验证码
});

//首页
Route::group('stat', function () {
    Route::post('list', 'Stat/list');//统计
})->middleware(Token::class);

//用户管理
Route::group('user', function () {
    Route::post('list', 'AdminUser/list');//列表
    Route::post('create', 'AdminUser/add');//添加
    Route::post('modify', 'AdminUser/edit');//修改
    Route::post('modify_status', 'Admin/edit');//修改
    Route::post('del', 'AdminUser/del');//删除
    Route::post('select', 'AdminUser/search');//查询
    //角色
    Route::group('role', function () {
        Route::post('list', 'AdminRole/list');//列表
        Route::post('create', 'AdminRole/add');//添加
        Route::post('modify', 'AdminRole/edit');//修改
        Route::post('details', 'AdminRole/detail');//详情
        Route::post('modify_status', 'AdminRole/editStatus');//修改状态
        Route::post('del', 'AdminRole/del');//删除
        Route::post('select', 'AdminRole/search');//查询
    });
    //菜单
    Route::group('menu', function () {
        Route::post('list', 'AdminMenu/list');//列表
        Route::post('create', 'AdminMenu/add');//添加
        Route::post('modify', 'AdminMenu/edit');//修改
        Route::post('details', 'AdminMenu/detail');//详情
        Route::post('modify_status', 'AdminMenu/editStatus');//修改状态
        Route::post('del', 'AdminMenu/del');//删除
        Route::post('select', 'AdminMenu/search');//查询
    });
})->middleware(Token::class);


//商品
Route::group('goods', function () {
    Route::post('list', 'Goods/list');//列表
    Route::post('create', 'Goods/add');//添加
    Route::post('modify', 'Goods/edit');//修改
    Route::post('details', 'Goods/detail');//详情
    Route::post('modify_status', 'Goods/editStatus');//修改状态
    Route::post('del', 'Goods/del');//删除
    Route::post('select', 'Goods/search');//查询
    Route::post('download_template', 'Goods/downloadTemplate');//模版下载
    Route::post('import', 'Goods/import');//导入
    Route::post('import_excel', 'Goods/importExcel');//导入表格 TODO 注意模型中钩子函数，慎用！
    //商品分类
    Route::group('cate', function () {
        Route::post('list', 'GoodsCate/list');//分类列表
        Route::post('create', 'GoodsCate/add');//分类添加
        Route::post('modify', 'GoodsCate/edit');//分类修改
        Route::post('modify_status', 'GoodsCate/editStatus');//分类修改
        Route::post('details', 'GoodsCate/detail');//分类详情
        Route::post('del', 'GoodsCate/del');//分类删除
        Route::post('select', 'GoodsCate/search');//查询
    });
})->middleware(Token::class);

//公司
Route::group('company', function () {
    Route::post('list', 'Company/list');//列表
    Route::post('create', 'Company/add');//添加
    Route::post('modify', 'Company/edit');//修改
    Route::post('details', 'Company/detail');//详情
    Route::post('modify_status', 'Company/editStatus');//修改状态
    Route::post('del', 'Company/del');//删除
    Route::post('select', 'Company/search');//查询
})->middleware(Token::class);

//公司员工
Route::group('company_user', function () {
    Route::post('select', 'CompanyUser/search');//查询
})->middleware(Token::class);

//订单
Route::group('order', function () {
    Route::post('list', 'CompanyOrder/list');//列表
    Route::post('details', 'CompanyOrder/detail');//详情
    Route::post('select', 'CompanyOrder/search');//查询
    Route::get('pass', 'CompanyOrder/editStatus')->append(['order_status' => 2]);//审核同意
    Route::get('reject', 'CompanyOrder/editStatus')->append(['order_status' => 4]);//审核拒绝
})->middleware(Token::class);

//财务管理
Route::group('finance', function () {
    Route::group('store', function () {
        Route::post('list', 'StoreOrder/profit');//列表
        Route::get('pass', 'StoreOrder/edit')->append(['settlement_status' => 2]);//审核同意
    });
    //分红设置
    Route::group('dividend', function () {
        Route::post('list', 'AdminDividend/list');//列表
        Route::post('modify', 'AdminDividend/edit');//修改
        Route::post('del', 'AdminDividend/del');//删除
        Route::post('dividend', 'AdminDividend/dividend');//开始分红
        Route::post('user', 'AdminDividend/userList');//用户分红列表
        Route::post('user_detail', 'AdminDividend/userDividendDetail');//用户分红明细
    })->middleware(Token::class);
})->middleware(Token::class);


//上传
Route::rule('upload/:action','upload/:action')->middleware(CheckDomain::class); //该中间件用于检测当前域名是否合法
